package com.cn.wanxi.servlet;

import com.alibaba.fastjson.JSONObject;
import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.model.NavModel;
import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.service.ICompanyService;
import com.cn.wanxi.service.INavService;
import com.cn.wanxi.service.IProductService;
import com.cn.wanxi.service.impl.CompanyServiceImpl;
import com.cn.wanxi.service.impl.NavServiceImpl;
import com.cn.wanxi.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/home")
public class HomeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


//        req.setAttribute("navModelList", navModelList);//key  value
//新闻信息
//        NewsService newsService = new NewsService();
//        List<NewsModel> newsModelList = newsService.getNewsModelList();
//        req.setAttribute("newsModelList", newsModelList);//key  value
        IProductService iProductService = new ProductServiceImpl();
        List<ProductModel> productModelList = iProductService.findForHome();
//        req.setAttribute("productModelList", productModelList);

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("productModelList", productModelList);
        resp.getWriter().println(jsonObject);
    }
}
